package com.example.mydemo.controller;

import com.example.mydemo.entity.User;
import io.swagger.annotations.ApiOperation;
import org.mapstruct.AfterMapping;
import org.springframework.web.bind.annotation.*;

@RestController
public class FirstController {
//    url = /first？username=XX
//    @RequestMapping("/first")
    @GetMapping("/first")
    @ApiOperation("first接口")
    public String hello() {
        return "my SpringBoot123456789 ";
    }

    @GetMapping("/getTest")
    public  String getTest(@RequestParam("name") String username) {
        System.out.println(username);
        return "get有参";
    }

//    @GetMapping("/getTest2")
//    public User getUser(){
//        User user  = new User();
//        user.setUsername("zhangsan");
//        user.setPhone("123456");
//        return user;
//    }

//    @GetMapping("/user1/{id}")
//    public String getUserById1(@PathVariable  int id){
//        System.out.println(id);
//        return "查找特定的用户";
//    }


//    @PostMapping("/postTest1")
//    public String save(String username,String pwd) {
//        System.out.println(username);
//        System.out.println(pwd);
//        return "post有参";
//    }
//
//    @PostMapping("/postTest2")
//    public String save2(User user){
//        System.out.println(user.getUsername());
//        System.out.println(user.getPwd());
//        System.out.println(user.getPhone());
//        return "收到对象";
//    }
//
    @PostMapping("/postTest3")
    public String save3(@RequestBody User user){
        System.out.println(user.getName());
        System.out.println(user.getPhone());
        System.out.println(user);
        return "收到对象";
    }



}
